home *** CD-ROM | disk | FTP | other *** search
- /* program to let a user browse through an indexed document/database
- * ... works with indices created by ndxr.c program ...
- * by ^z - 870805-13-...
- *
- */
-
-
- /* main function does the work of interpreting the user's commands:
- *
- * ? print out helpful info
- * : quit program
- * :fnord open document file 'fnord' for browsing
- * >grok append copy of future output to notes file 'grok'
- * > end copying to notes file
- * 'DON.MAC append comment string 'DON.MAC' to notes file
- * xyzzy jump to INDEX item 'XYZZY'
- * ".012345 take string '.012345' as target for jump
- * -17 back up 17 lines from here
- * - back up one line; same as '-1' command
- * +23 jump down 23 lines from here
- * + or <ret> move down one line; same as '+1' command
- * .29 print 29 lines from here
- * = descend: INDEX -> CONTEXT -> TEXT display
- * ^ ascend: TEXT -> CONTEXT -> INDEX display
- * * empty 'working subset' proximity filter (nothing valid)
- * ** fill 'working subset' (everything valid)
- * & add word-neighborhood of current index item to subset
- * && add sentence-neighborhood to subset
- * &&& add paragraph-neighborhood to subset
- * ~ invert (logical NOT) entire working subset
- * ; repeat previous command
- *
- */
-
-
- #include <stdio.h> /* for FILE, printf(), etc. */
- #include <strings.h> /* for strcpy(), etc. */
- #include <proto.h> /* for function prototypes */
- #include "brwsr.h" /* for various of my definitions */
- #include "brwsr.proto.h" /* for my function prototypes */
-
-
- /* First, define a few external variables to hold:
- * - pointers to the document, key, pointer, and notes files;
- * - numbers indicating the current and the minimum/maximum values for:
- * INDEX item (one line for each unique word in the document);
- * CONTEXT item (one line for each occurrence of chosen INDEX word);
- * TEXT item (byte offset from start of file to current line).
- * - the actual KEY_RECs corresponding to the current INDEX item and
- * the INDEX item just before that one
- * - the subset array pointer used for proximity searching, the flag
- * empty_subset, and the count of how many current records are in
- * the working subset subset_rec_count
- * - the level of user operations:
- * 0 means browsing the INDEX
- * 1 means browsing the CONTEXT (key-word-in-context = KWIC)
- * 2 means browsing the TEXT
- *
- * These items are referred to by various routines at scattered
- * locations, and it seems easiest to let them reside in external
- * variables....
- */
-
- FILE *doc_file = NULL, *key_file = NULL, *ptr_file = NULL,
- *notes_file = NULL;
- long current_item[3] = {0, 0, 0};
- long min_item[3] = {0, 0, 0};
- long max_item[3] = {0, 0, 0};
- KEY_REC this_rec, prev_rec;
- char *subset = NULL;
- int empty_subset = TRUE;
- long subset_rec_count = 0;
- int level = INDEX;
-
- void main()
- {
- char cmd[STRLEN], prevcmd[STRLEN], *gets(), *strcpy();
-
- prevcmd[0] = '\0';
- printf ("Greetings, program! ... type '?' for help.\n");
- printf ("Browser version 0.2 by ^z - 28-letter keys - 871103\n");
-
- while (gets (cmd))
- {
- do_cmd:
- switch (cmd[0])
- {
- case '?':
- do_help ();
- break;
- case '\0':
- strcpy (cmd, "+");
- /* <return> is just + */
- case '+':
- /* + or - commands are both moves */
- case '-':
- do_move (cmd);
- break;
- case ':':
- do_open (cmd);
- break;
- case '>':
- do_redirection (cmd);
- break;
- case '\'':
- do_comments (cmd);
- break;
- case '=':
- do_descend ();
- break;
- case '^':
- do_ascend ();
- break;
- case '.':
- do_multiprint (cmd);
- break;
- case '*':
- do_make_subset (cmd);
- break;
- case '&':
- do_add_neighborhood (cmd);
- break;
- case '~':
- do_invert_subset ();
- break;
- case ';':
- strcpy (cmd, prevcmd);
- goto do_cmd;
- break;
- case '"':
- do_target_jump (cmd + 1);
- break;
- default:
- do_target_jump (cmd);
- break;
- }
- strcpy (prevcmd, cmd);
- }
- }
-
-